package com.example.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.common.R;
import com.example.model.req.AddCommentReq;
import com.example.service.CommentService;

@ResponseBody
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("/add")
    public R<String> addComment(@RequestBody AddCommentReq addCommentReq, HttpServletRequest request) {
        return commentService.addComment(addCommentReq, request);
    }

    @GetMapping("/hasCommented/{orderId}")
    public R<Boolean> hasCommented(@PathVariable("orderId") Integer orderId,
            @RequestParam("orderType") boolean orderType) {
        return commentService.hasCommented(orderId, orderType);
    }
}
